module.exports = {
    getFirstArgumentOfServiceMethod(node) {
      return node.arguments[0];
    },
    getEventTypeName(node) { // 获取事件类型
			const eventType = this.getFirstArgumentOfServiceMethod(node);
			if (eventType === undefined) {
				return;
			}
			if (eventType.type === 'Literal') {
				return eventType.value;
			}
			if (eventType.type === "Identifier") {
				return eventType.name;
			}
			if(eventType.type === "MemberExpression") {
				if(eventType.property) {
					return eventType.property.name;
				}                
			}
    },
		getCallExpression(node) {
			const callee = node.callee;
			if(callee) {
				return {
					targetObj: callee.object ? callee.object.name : '',
					methodName: callee.property ? callee.property.name : '',
				};
			}
		},
		getNotifyCallExpression(node) {
			const callee = node.callee;
			return callee.name
		},
		isAssignExpression(node) {
			const parentNode = node.parent;
			if (parentNode.type === 'VariableDeclarator') { // 赋值node
				const id = parentNode.id;
				return {
					assignVariable: id.name
				};
			}
			if (parentNode.type === 'AssignmentExpression') {
				const left = parentNode.left;
				return {
					assignVariable: left.property.name,
				};
			}
			return;
		},
		getMemberCallExpression(node) {
			const callee = node.callee;
			if(callee) {
				return {
					targetObj: callee.object && callee.object.property ? callee.object.property.name : '',
					methodName: callee.property ? callee.property.name : '',
				};
			}
		}
}